package com.security.door.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.security.door.core.base.BaseService;
import com.security.door.dao.mapper.crAreaDeviceMapper;
import com.security.door.model.domain.crArea;
import com.security.door.model.domain.crAreaDevice;
import com.security.door.model.dto.crAreaDeviceDto;
import com.security.door.model.vo.crAreaDeviceVo;
import com.security.door.service.IcrAreaDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class crAreaDeviceServiceImpl extends BaseService<crAreaDevice> implements IcrAreaDeviceService {

    @Autowired
    crAreaDeviceMapper icrAreaDeviceMapper;

    public PageInfo<crAreaDeviceVo> queryListWithPage(crAreaDeviceDto entity) {
        PageHelper.startPage(entity.getPageIndex(), entity.getPageSize());
        var actionList = icrAreaDeviceMapper.queryListWithPage(entity);
        return new PageInfo<>(actionList);
    }

    public boolean hasdeviceGrant(String guid) {
        return icrAreaDeviceMapper.hasdeviceGrant(guid) > 0 ? true : false;
    }

    public PageInfo<crArea> selectByCode(crAreaDeviceDto entity) {
        PageHelper.startPage(entity.getPageIndex(), entity.getPageSize());
        var actionList = icrAreaDeviceMapper.selectByCode(entity);
        return new PageInfo<>(actionList);
    }

    public boolean hasExists(crAreaDevice entity) {
        return icrAreaDeviceMapper.hasExists(entity) > 0 ? true : false;
    }
}
